package cn.edu.ldu.communityqa.communityqa.service;

import cn.edu.ldu.communityqa.communityqa.dao.QuestionDao;
import cn.edu.ldu.communityqa.communityqa.entity.Question;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionService {
    private final QuestionDao questionDao;

    @Autowired
    public QuestionService(QuestionDao questionDao) {
        this.questionDao = questionDao;
    }

    public List<Question> findAll() {
        return questionDao.findAll();
    }

    public Question findById(Long id) {
        return questionDao.findById(id);
    }

    public int save(Question question) {
        return questionDao.save(question);
    }

    public int update(Question question) {
        return questionDao.update(question);
    }

    public int deleteById(Long id) {
        return questionDao.deleteById(id);
    }

    public List<Question> findByTitleLike(String title) {
        return questionDao.findByTitleLike(title);
    }

}
